package com.example.test;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.example.test.bean.GW;
import com.example.test.bean.MySQLiteOpenHelper_1;

import java.util.List;

public class QueryActivity extends AppCompatActivity {
    TextView textView;
    String cph,rq1,rq2,z1,z2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_query);
    }

    public void query_btn(View view){
        textView=findViewById(R.id.tv_result);
        EditText editText=findViewById(R.id.carNumber);
        String cp=editText.getText().toString();
        MySQLiteOpenHelper_1 helper_1=new MySQLiteOpenHelper_1(this);
        List<GW> list=helper_1.query(cp);
        int z3;
        for ( GW gw: list){
            cph=gw.getCarNumber();
            rq1=gw.getDate_1();
            rq2=gw.getDate_2();
            z1=gw.getW_1();
            z2=gw.getW_2();
        }
        System.out.println(z1+z2);
        z3=Integer.parseInt(z1)-Integer.parseInt(z2);
        textView.setText("车牌:"+cph+"  毛重日期:"+rq1+"  毛重:"+z1+"  皮重日期:"+rq2+"  皮重:"+z2+"  净重:"+z3);
    }
}